/**
 * 
 */
package com.etc.admin.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.etc.admin.dao.EmployeeMapper;
import com.etc.admin.service.EmployeeService;
import com.etc.entity.Employee;
import com.etc.util.PageData;

/**
 * @author ccq
 *
 *date: 2019年4月28日 下午2:49:58
 */
@Repository(value = "employeeService")
public class EmployeeServiceImpl implements EmployeeService {

	@Resource(name = "employeeMapper")
	private EmployeeMapper employeeMapper;

	@Override
	public Employee selectEmployeeById(Integer empid) {
		
		return employeeMapper.selectEmployeeById(empid);
	}

	@Override
	public PageData<Employee> getEmployeeByPage(int page, int pageSize, String content) {

		// 之前的业务判断，此时在这里完成
		int start = (page - 1) * pageSize;

		// 查询需要返回的核心数据[指定页码的]
		List<Employee> data = employeeMapper.selectByPage(start, pageSize, content);
		// 查询满足条件的记录数
		int count = employeeMapper.selectCount(content);
		PageData<Employee> pd = new PageData<>(data, count, pageSize, page);

		return pd;
	}

	
	@Override
	public boolean addEmployee(Employee employee) {
		
		if(employee==null) {
			return false;
		}
		return employeeMapper.addEmployee(employee)>0;
	}

	@Override
	public boolean updateEmployee(Employee employee) {
		if(employee==null) {
			return false;
		}
		return employeeMapper.updateEmployee(employee)>0;
	}

	@Override
	public Employee selectEmpByEmpNameAndEmpPwd(String empName, String empPwd) {
		// TODO Auto-generated method stub
		return employeeMapper.selectEmpByEmpNameAndEmpPwd(empName, empPwd);
		
	}



}
